package com.amado.course28Exception;

public class S07TestApiCheckedException {
	public static void main(String[] args) {
		S05ApiCheckedException apiException = null;
		try {
			addStudent("张三", null);
		} catch (S05ApiCheckedException e) {
			apiException = e;
		}
		if (apiException != null) {
			System.out.println(apiException.getErrorMessage());
		} else {
			System.out.println("添加成功");
		}
	}

	public static void addStudent(String studentName, String phone) throws S05ApiCheckedException{
		if (studentName == null) {
			throw new S05ApiCheckedException("001","姓名不能为空");
		}
		if (phone == null) {
			throw new S05ApiCheckedException("002","电话号码不能为空");
		}
	}
}
